<template>
	<div class="train-teacher-statistics maxW">
		<div class="crumbs-link">
			<router-link to="/train/index">培训列表</router-link>
			<router-link to="/train/manage/index"><i>></i>培训管理</router-link>
			<!-- <router-link to="/train/manage/index"><i>></i>培训管理</router-link> -->
			<strong><i>></i>批阅</strong>
		</div>

		<div class="train-teacher-statistics-wp">
			<div class="train-teacher-statistics-title">
				<span>{{name === name ? name : '试卷列表'}}</span>
			</div>
			<div class="train-teacher-statistics-content" v-loading='loading' v-if="reviewList.length !== 0">
				<p>作答细明</p>
				<template>
					<el-table
					border
					:data="reviewList"
					style="width: 100%">
						<el-table-column
							type="index"
							label="序号"
							width="50"
							align="center">
						</el-table-column>
						<el-table-column
						prop="uname"
						label="用户名"
						width=""
						show-overflow-tooltip>
						</el-table-column>
						<el-table-column
						prop="unumber"
						label="用户账号"
						width=""
						show-overflow-tooltip>
						</el-table-column>
						<el-table-column
						prop="position_name"
						label="地区"
						width=""
						show-overflow-tooltip>
						</el-table-column>
						<el-table-column
						prop="school_name"
						label="学校"
						width=""
						show-overflow-tooltip>
						</el-table-column>
						<el-table-column
						prop="mark_status"
						label="试卷状态"
						width=""
						align="center"
						show-overflow-tooltip>
							<template slot-scope="scope">
								<template v-if="scope.row.mark_status == 0">
									<span>待批阅</span>
								</template>
								<template v-if="scope.row.mark_status == 1">
									<span>已批阅</span>
								</template>
							</template>
						</el-table-column>
						<el-table-column
						prop="total_score"
						label="总分"
						width=""
						align="center"
						show-overflow-tooltip>
						</el-table-column>
						<el-table-column
						prop="answer_score"
						label="得分"
						width=""
						align="center"
						show-overflow-tooltip>
						</el-table-column>
						<el-table-column
						prop="operation"
						label="操作"
						width="100"
						align="center"
						class-name="operation"
						show-overflow-tooltip>
							<template slot-scope="scope">
								<template v-if="scope.row.answer_status == 1">
									<router-link 
									class="answer_status"
									:to="{path: '/train/test-review',query: {record_id: scope.row.id,train_little_id: train_little_id,user_id: scope.row.user_id,create_id: scope.row.teacher_id}}" 
									v-if="scope.row.mark_status == 0">批阅</router-link>
									<router-link 
									class="answer_status"
									:to="{path: '/train/test-see',query: {record_id: scope.row.id,train_little_id: train_little_id,user_id: scope.row.user_id,create_id: scope.row.teacher_id}}" 
									v-if="scope.row.mark_status == 1">查看</router-link>
								</template>
								<template  v-if="scope.row.answer_status == 0">
									<span class="status_op">未完成</span>
								</template>
							</template>
						</el-table-column>
					</el-table>
				</template>

				<el-pagination
				 	 background
				 	 v-if="total_number > page_size"
				 	 class="pageing"
				     @size-change="sizeChange"
				     @current-change="currentChange"
				     :current-page="page_index"
				     :page-size="page_size"
				     layout="total, prev, pager, next, jumper"
				     :total="total_number">
				</el-pagination>
			</div>

			<div class="dependent" v-if="placeholder">
				<i class="ipng image_state01"></i>
				<p>还没发现任何相关的内容哦~</p>
			</div>
		</div>
	</div>
</template>

<script>

	
	export default{     
		data() {
			return {
				page_size: this.$g.page_size,
				page_index: 1,
				total_number: 0,
				placeholder: false,
				loading: false,
				reviewList: [],
				trainid: this.$route.query.trainid,
				train_little_id: this.$route.query.train_little_id,
				test_id: this.$route.query.test_id,
				name: this.$route.query.name,
				
			}
		},
		created(){
			console.info(this.trainid, this.train_little_id, this.res_id, this.name)
			this.get_reviewList()
		},
		methods: {
			get_reviewList(){
				let success = ( res=>{
					let data = res.data;
					this.reviewList = data.data;
					this.total_number = parseInt(data.data_sum);
					
					this.loading = false;
					this.reviewList.length === 0
					? this.placeholder = true
					: this.placeholder = false
				});

				this.$ajax({
					url: 'api/test/get_test_list',
					method: 'get',
					params: {
						train_id: this.trainid,
						train_little_id: this.train_little_id,
						test_id: this.test_id,
						page_index: this.page_index,
						page_size: this.page_size,
					},
					func: {success: success}
				})
			},
			goback(){
				this.$router.back(-1)
			},
			sizeChange(val) {
				this.page_size = val;
				this.get_reviewList()
			},
			currentChange(val) {
				this.page_index = val;
				this.get_reviewList()
			}
		}
	}
</script>